package org.blogwu.jvm_learn.controller;


import org.blogwu.jvm_learn.filters.UserFilters;
import org.blogwu.jvm_learn.service.AdminService;
import org.blogwu.jvm_learn.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    public AdminService adminService;

    @Autowired
    public UserService userService;


    @RequestMapping("/hello")
    public String hello() {
        return "hello world";
    }

    @RequestMapping("/getUid")
    public String getUid(String userName) {
        String uid = UserFilters.requestId.get();
        adminService.add(userName);
        System.out.println("UserController  getUid:" + UserFilters.requestId.get() + ":" + userName);
        return uid;
    }

    @RequestMapping("/getUid2")
    public String getUid2(String userName) {
        String uid = UserFilters.requestId.get();
        userService.add(userName);
        System.out.println("UserController  getUid2:" + UserFilters.requestId.get() + ":" + userName);
        return uid;
    }


}
